<template>
	<view class="" style="width: 100vw;height: 100vh">
		<!-- <view  style="min-height: 100vh">
			<image class="bg" src="/static/login/log_bg.png" mode="scaleToFill"></image> -->
		<view class="content" :style="{'background':kbackgroundColor}" style="min-height: 100vh">
		
			<hx-navbar title="积分明细" :back="true" :fixed="false" :color="knavTitleColor" barPlaceholder="hidden"
				transparent="auto"></hx-navbar>
			<view class="wrapper">
				<view class="list">
					<template v-for="(item, index) in list">
						<view class="item" :key="index">
							<view class="info">
								<view class="title">
									<image src="/static/shop/price_icon.png" mode="scaleToFill"></image>
									<view class="text">{{item.subject}}</view>
								</view>
								<view class="num">订单编号:{{item.tradeNo}}</view>
								<view class="time">{{item.createTime|filterTime}}</view>
							</view>
							<view class="point" :style="[selStyle]" :class="{'up': item.type!=2}">
								{{item.type==1?'+'+item.amount:'-'+item.amount}}
							</view>
						</view>
					</template>
				</view>
				<view class="none" style="text-align: center;" v-if='list.length===0'>
					<image src="@/static/without.png" style="width:550rpx;margin: 10rpx auto;" alt="" mode="widthFix">
					</image>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				selStyle: {
					'--selectColorSize': this.$store.state.selectColorSize, //字体颜色
					'--buttonBcak': this.$store.state.buttonBcak,
				},
				list: [],
				page: 1,
				limit: 16,
				last: false
			};
		},
		filters: {
			filterTime(val) {
				return uni.$u.timeFormat(parseInt(val), 'yyyy-mm-dd hh:MM')
			}
		},
		onLoad() {
			this.getPointList();
		},
		onPullDownRefresh() {
			this.page = 1;
			this.getPointList();
			setTimeout(() => {
				uni.stopPullDownRefresh();
			}, 300);
		},
		onReachBottom() {
			if (!this.last) {
				this.page++;
				this.getPointList();
			}
		},
		methods: {
			// 列表
			getPointList() {
				this.$api.getPointList({
					pageNo: this.page,
					// limit: this.limit
				}, res => {
					if (res.status) {
						if (res.data.length == 0) return this.last = true;
						if (this.page == 1) {
							this.list = res.data;
						} else {
							this.lsit = [...this.list, ...res.data];
						}
					}
				});
			},
		}
	}
</script>

<style lang="scss" scoped>
	.wrapper {
		padding: 20rpx 30rpx 50rpx;
		position: relative;
		z-index: 2;

		.list {
			width: 100%;

			.item {
				width: 100%;
				padding: 25rpx 20rpx 30rpx 40rpx;
				background-color: #fff;
				border-radius: 10rpx;
				margin-bottom: 20rpx;
				display: flex;
				align-items: center;
				justify-content: space-between;

				.info {
					.title {
						display: flex;
						align-items: center;

						image {
							width: 38rpx;
							height: 40rpx;
							display: block;
							margin-right: 12rpx;
						}

						.text {
							width: 420rpx;
							font-size: 28rpx;
							color: #333435;
							font-weight: bold;
							overflow: hidden;
							text-overflow: ellipsis;
							white-space: nowrap;
						}
					}

					.num,
					.time {
						padding-left: 50rpx;
						font-size: 22rpx;
						color: #999;
						margin: 6rpx 0;
					}

					.time {
						margin: 0;
					}
				}

				.point {
					margin-left: 20rpx;
					font-size: 28rpx;
					color: #333;
					font-weight: bold;
				}

				.point.up {
					color: var(--selectColorSize); //#FE005A;
				}
			}

			&>view:last-child {
				margin-bottom: 0;
			}
		}
	}
</style>